package sysuser

import (
	"go-caipu/pkg/services/dto"
	"time"
)

type GetUserPageCommand struct {
	dto.Pagination  `search:"-"`
	NickName        string   `json:"nickname"  search:"type:contains;column:nickName;table:sys_user"`
	Username        string   `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
	Phone           string   `form:"phone" search:"type:contains;column:phone;table:sys_user" comment:"昵称"`
	DeptId          string   `form:"deptId" search:"type:exact;column:dept_id;table:sys_user" comment:"岗位"`
	Status          string   `form:"status" search:"type:exact;column:status;table:sys_user" comment:"状态"`
	RoleIds         []string `form:"roleIds" search:"-"`
	ExcludedRoleIds []string `json:"-" search:"-"` //查询时排除的角色ID用户

	//排除角色用户
	NoExcludeRoleUser []string `json:"-" search:"-"`
	CreateTime        []string `form:"createTime" search:"-"`
	BeginTime         string   `form:"beginTime" search:"type:gte;column:created_at;table:sys_user" comment:"创建时间"`
	EndTime           string   `form:"endTime" search:"type:lte;column:created_at;table:sys_user" comment:"创建时间"`
}

func (m *GetUserPageCommand) GetNeedSearch() interface{} {
	return *m
}

type GetUserRequest struct {
	Name    string   `json:"name"`
	RoleIds []string `json:"roleIds" gorm:"-"`
}
type WorkUserInfo struct {
	ID     int64  `json:"id,string"`
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
	DeptId int64  `json:"deptId,string"`
}
type User struct {
	UserId    int64    `json:"id,string" comment:"用户ID"` // 用户ID
	Username  string   `json:"username" comment:"用户名" vd:"len($)>0"`
	Password  string   `json:"password" comment:"密码"`
	Salt      string   `json:"-" gorm:"type:varchar(255);comment:加盐"`
	NickName  string   `json:"nickname" comment:"昵称" vd:"len($)>0"`
	Phone     string   `json:"phone" comment:"手机号" vd:"len($)>0"`
	RoleIds   []string `json:"roleIds" gorm:"-"`
	RoleNames []string `json:"roleNames" gorm:"-"`
	Avatar    string   `json:"avatar" comment:"头像"`
	Sex       int      `json:"gender" comment:"性别"`
	Email     string   `json:"email" comment:"邮箱" vd:"len($)>0,email"`
	//DeptId   int     `json:"deptId" comment:"部门" vd:"$>0"`
	//Dept UsDept `json:"dept"`
	UsDept
	PostId           int    `json:"postId" comment:"岗位"`
	Remark           string `json:"description" comment:"备注"`
	Status           int    `json:"status" comment:"状态" vd:"len($)>0" default:"1"`
	CreatedAt        string `json:"createTime"`
	CreateUserString string `json:"createUserString"`
	UpdatedAt        string `json:"updatedAt"`
	UpdateUserString string `json:"updateUserString"`
	dto.ControlBy
}
type UsDept struct {
	DeptId   int64  `json:"deptId,string"`
	DeptName string `json:"deptName"`
}
type InsertUserCommand struct {
	UserId    int64        `json:"id,string" comment:"用户ID"` // 用户ID
	Username  string       `json:"username" comment:"用户名" vd:"len($)>0"`
	Password  string       `json:"password" comment:"密码"`
	NickName  string       `json:"nickName" comment:"昵称" vd:"len($)>0"`
	Phone     string       `json:"phone" comment:"手机号" vd:"len($)>0"`
	RoleIds   []string     `json:"roleIds" gorm:"-"`
	Avatar    string       `json:"avatar" comment:"头像"`
	Sex       int          `json:"gender" comment:"性别"`
	Email     string       `json:"email" comment:"邮箱" vd:"len($)>0,email"`
	DeptId    int64        `json:"deptId,string" comment:"部门" vd:"$>0"`
	PostId    int          `json:"postId" comment:"岗位"`
	Remark    string       `json:"remark" comment:"备注"`
	Status    int          `json:"status" comment:"状态"`
	ThirdUser UserThirdReq `json:"-" gorm:"-"`
	dto.ControlBy
	CreateUserString string `json:"createUserString"`
	UpdateUserString string `json:"updateUserString"`
}
type UpdateUserCommand struct {
	UserId   int64    `json:"id,string" comment:"用户ID"` // 用户ID
	Username string   `json:"username" comment:"用户名" vd:"len($)>0"`
	NickName string   `json:"nickName" comment:"昵称" vd:"len($)>0"`
	Phone    string   `json:"phone" comment:"手机号" vd:"len($)>0"`
	RoleIds  []string `json:"roleIds,string" gorm:"-"`
	Avatar   string   `json:"avatar" comment:"头像"`
	Sex      int      `json:"gender" comment:"性别"`
	Email    string   `json:"email" comment:"邮箱" vd:"len($)>0,email"`
	DeptId   int64    `json:"deptId,string" comment:"部门" vd:"$>0"`
	PostId   int      `json:"postId" comment:"岗位"`
	Remark   string   `json:"remark" comment:"备注"`
	Status   int      `json:"status" comment:"状态"`
	dto.ControlBy
}

type GetUserCommand struct {
	UserId int64 `uri:"id"`
}
type RemoveUserCommand struct {
	Ids []string `json:"ids"`
	Id  string   `uri:"id"`
}
type UpdatePwdCommand struct {
	UserId      int64  `json:"-"`
	NewPassword string `json:"newPassword" vd:"len($)>0"`
	Salt        string `json:"-"`
	OldPassword string `json:"oldPassword" vd:"len($)>0"`
	dto.ControlBy
}
type UpdateUserStatusCommand struct {
	UserId int64  `json:"userId" comment:"用户ID" vd:"$>0"` // 用户ID
	Status string `json:"status" comment:"状态" vd:"len($)>0"`
	dto.ControlBy
}
type ResetPasswordCommand struct {
	UserId   int64  `uri:"userId" comment:"用户ID"` // 用户ID
	Password string `json:"newPassword" comment:"密码" vd:"len($)>0"`
	Salt     string `json:"-"`
	dto.ControlBy
}
type UpdateUserAvatarReq struct {
	Avatar    string    `json:"avatar"`
	UpdateBy  int64     `json:"updateBy" gorm:"index;comment:更新者"`
	UpdatedAt time.Time `json:"updatedAt"`
}
type UpdateUserRole struct {
	UserId       int64    `uri:"userId" comment:"用户ID" vd:"$>0"` // 用户ID
	RoleIds      []string `json:"roleIds,string" gorm:"-"`
	UpdateUserId string
}
type UpdateUserBasicInfoReq struct {
	UserId   int64  `json:"-"` // 用户ID
	NickName string `json:"nickname" comment:"昵称" vd:"len($)>0"`
	Gender   int    `json:"gender" comment:"性别" vd:"$>0"`
}
type UserThirdReq struct {
	ThirdType string `json:"thirdType"`
	ThirdId   string `json:"thirdId"`
	UserId    int64  `json:"userId"`
}
